package com.example.logistics_manage.controller;

import com.example.logistics_manage.pojo.Cargo;
import com.example.logistics_manage.result.restful.R;
import com.example.logistics_manage.result.restful.ResponseEunm;
import com.example.logistics_manage.service.ICargoService;
import com.example.logistics_manage.service.serviceImpl.CargoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/cargo")
@CrossOrigin
public class CargoController {

    @Autowired
    ICargoService cargoService;
    @GetMapping("/findCargoById/{cargoId}")
    R<Cargo> findCargoById(@PathVariable("cargoId") Integer cargoId) {
        return new R<>(ResponseEunm.SUCCESS, cargoService.findCargoById(cargoId));
    }
    @PostMapping("/updateCargo")
    public R<?> updateCargo(@RequestBody Cargo cargo){
        System.out.println(cargo);
        cargoService.updateCargo(cargo);
        return new R<>(ResponseEunm.SUCCESS,null);
    }
}
